﻿#pragma once
#include <QWidget>
#include <QScopedPointer>
#include <QPointer>

class PropertyEditViewUi;
class PropertyEditEntry;
class Groupbox;

class PropertyEditView : public QWidget {
    Q_OBJECT
    friend class PropertyEditViewUi;
private:
    QScopedPointer<PropertyEditViewUi> ui;
    struct PropertyEditorData;
    QScopedPointer<PropertyEditorData> p;
public:
    explicit PropertyEditView(QWidget *parent = nullptr);
    ~PropertyEditView();
    void appendPropertyEditEntry(PropertyEditEntry *entry);
    void setCurrentEntry(Groupbox *entry);
    QList<int> headerSizes();

public slots:
    void editObject(QPointer<QObject> object);

protected:
    void resizeEvent(QResizeEvent *event) override;

private slots:
    void onCurrentChanged(QPointer<QObject> current, const QPointer<QObject> previous);
    void onEntryExpandedOrCollapsed();
    void onHeaderSplitterMoved();

private:
    void createEditEntryFor(const QMetaObject &metaObject);
};
